#include<math.h>
#include<stdio.h>

#define PI 3.14159265358979323846
#define N 100

float n=sqrt(PI*N/(2*sqrt(3)));
float fun(float theta);

int main ()
{
	float x,y,z, theta1=0, theta2=0;
	int i=0;
	
	i++;
	for (theta1=0;theta1<2*n*PI;theta1=theta2)
	{
		theta2=fun(theta1);		
		
		printf("theta1=%3f theta2=%3f\n",theta1,theta2);
		x=cos(0.5*(theta1/n-PI))*cos(theta1);	
		y=cos(0.5*(theta1/n-PI))*sin(theta1);
		z=-1*sin(0.5*(theta1/n-PI));
		printf("%d(%3f , %3f ,%3f)\n\n",i,x,y,z); 
		i++;
	}

	

	x=0;
	y=0;
	z=-1;
	printf("%d(%3f , %3f ,%3f)\n\n",i,x,y,z); 
	printf("%d %f",i,2*sqrt(3)*n*n/PI);
	return 0;
}	


float fun(float theta)
{
	return n*(2*asin(PI/(sqrt(3)*n*n)+sin(0.5*(theta/n-PI)))+PI);
}


/*void CreateSphere()
{
        Vertex VERTICES[N];

	float x,y,z, theta1=0, theta2=0;
	int i=0;
	int j=0;
	x=0.0;
	y=0.0;
	z=1.0;
	
	i++;

	for (theta1=0;theta1<2*n*PI;theta1=theta2) 
	{
		theta2=fun(theta1);		
		
		printf("theta1=%3f theta2=%3f\n",theta1,theta2);
		x=cos(0.5*(theta1/n-PI))*cos(theta1);	
		y=cos(0.5*(theta1/n-PI))*sin(theta1);
		z=-1*sin(0.5*(theta1/n-PI));
		VERTICES[j].Position[0]=x;
		VERTICES[j].Position[1]=y;
		VERTICES[j].Position[2]=z;
		VERTICES[j].Position[3]=1.0;

		VERTICES[j].Color[0]=1.0;
		VERTICES[j].Color[1]=0.8;
		VERTICES[j].Color[2]=0.0;
		VERTICES[j].Color[3]=1.0;
		j++;
		printf("%d(%3f , %3f ,%3f)\n\n",i,x,y,z); 
		i++;
	}

	

	x=0.0;
	y=0.0;
	z=-1.0;
		VERTICES[j].Position[0]=x;
		VERTICES[j].Position[1]=y;
		VERTICES[j].Position[2]=z;
		VERTICES[j].Position[3]=1.0;

		VERTICES[j].Color[0]=0.0;
		VERTICES[j].Color[1]=1.0;
		VERTICES[j].Color[2]=0.0;
		VERTICES[j].Color[3]=1.0;
	printf("%d(%3f , %3f ,%3f)\n\n",i,x,y,z); 
	printf("%d %f",i,2*sqrt(3)*n*n/PI);

        GLuint INDICES[N];
	for(i=0;i<N;i++)
	{
		INDICES[i]=i;
		printf("índice %d %d\n", i, INDICES[i]);
	}*/
